﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Security.Cryptography;
using System.Text;

namespace wuliuback
{
    public partial class RepublishGoods : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string id = Request["id"];
            string type = Request["type"];//1为货源，2为车源
            string date = DateTime.Now.ToString();

            string code = "";
            string msg = "";


            String sql = "";
            DbHelper dbHelper = new DbHelper();
            if (type == "1")
            {
                sql = "insert into t_goods select title, hy_bh, frompro3, fromcity3, fromcounty3, from_province, "+
                      "From_city, From_county, To_province, To_city, To_county, Course, Weight, Unit, hytj, "+
                      "hy_sl, hy_sldw, Note, Goods_type, Truck_info, hy_js, hy_sj, status, ischeck, User_id, "+
                      "User_name, hy_count, lx, getdate() as Created_time, phone, Mobile, Contact_Name, soft, "+
                      "truck_type, truck_length, remain_length, fee from t_goods where goods_id='" + id + "'";
            }
            else
            {
                sql = "insert into t_truck select Truck_title, cy_bh, From_province, From_city, From_county, To_province, "+
                      "To_city, To_county, cy_cph, cy_zz, Truck_type, Truck_length, Course, cy_fcsj, cy_sl, "+
                      "Company_name, Contact_Name, phone, Mobile, Address, Fax, email, wz, qq, hytj, "+
                      "cy_yc, cy_qt, cy_js, ischeck, cy_tj, user_id, User_name, cy_count, getdate() as Created_time," + 
                      "Weight, Unit, Note, Goods_type, hy_yq, status, Remain_length, fee, truck_info"+
                      " from t_truck where truck_id='" + id + "'";
            }

            if (dbHelper.Update(sql))
            {
                code = "0";
                msg = "重新发布成功";
            }
            else
            {
                code = "-1";
                msg = "重新发布失败";
            }
            
            Response.Output.WriteLine("{\"code\":\""+code+"\",\"msg\":\""+msg+"\"}");
        }
    }
}
